package com.xayy.health.mgt.mapper;

import cn.kawins.mybatis.BaseMapper;
import com.xayy.health.core.config.datasource.DatasourceSelector;
import com.xayy.health.mgt.model.CalculateData;
import com.xayy.health.mgt.model.DiagnoseFaultData;
import com.xayy.health.mgt.model.FaultInfo;
import com.xayy.health.mgt.model.TelemetryData;
import com.xayy.health.mgt.model.dto.FaultInfoDto;
import com.xayy.health.mgt.model.dto.MultiparatersDTO;
import com.xayy.health.mgt.model.vo.PredictDataVo;
import com.xayy.health.mgt.model.vo.TaskFaultPredictDataVo;
import com.xayy.health.mgt.model.vo.TaskResultVo;
import org.apache.ibatis.annotations.Param;

import java.util.ArrayList;
import java.util.List;

/**
 * 故障信息表 数据层
 *
 * @author cuixidong
 * @version 1.0
 **/
public interface FaultInfoMapper extends BaseMapper<FaultInfo> {

    /**
     * 分类统计故障信息
     *
     * @param nodeIds      节点id列表
     * @param faultInfoDto 故障入参
     * @return List<FaultInfo>
     */
    List<FaultInfo> selectFaultInfoList(@Param("nodeIds") List<Long> nodeIds, @Param("faultInfoDto") FaultInfoDto faultInfoDto);

    /**
     * 插入异常诊断自动任务的子任务的异常点信息
     *
     * @param diagnoseFaultDataList 异常点信息
     */
    @DatasourceSelector(sourceName = "clickhouse")
    void insertDiagnoseFaultDataList(@Param("diagnoseFaultDataList") List<DiagnoseFaultData> diagnoseFaultDataList);

    /**
     * 插入趋势预测自动任务的子任务的预测点信息
     *
     * @param calculateDataList 预测点信息
     */
    @DatasourceSelector(sourceName = "clickhouse")
    void insertCalculateDataList(@Param("calculateDataList") List<CalculateData> calculateDataList);

    /**
     * 获取子任务异常点信息集合
     *
     * @param taskId 任务id
     * @return List<TaskResultVo>
     */
    @DatasourceSelector(sourceName = "clickhouse")
    List<TaskResultVo> getTaskFaultDataList(@Param("taskId") Long taskId);

    /**
     * 获取任务预测点集合
     *
     * @param predictDataVo 预测点集合
     * @return List<TaskResultVo>
     */
    @DatasourceSelector(sourceName = "clickhouse")
    List<TaskResultVo> getTaskTrendDataList(PredictDataVo predictDataVo);

    /**
     * 获取预测段的实时数据
     *
     * @param predictDataVo 实时数据点集合
     * @return List<TelemetryData>
     */
    @DatasourceSelector(sourceName = "clickhouse")
    List<TelemetryData> getRealTimeDataList(PredictDataVo predictDataVo);


    /**
     * 插入事后诊断数据
     *
     * @param valueDTOList 入参
     */
    @DatasourceSelector(sourceName = "clickhouse")
    void insertDiagnoseParamsDataList(@Param("valueDTOList") ArrayList<MultiparatersDTO> valueDTOList);

    /**
     * 获取graph数据
     *
     * @param taskId 任务id
     * @return List<MultiparatersDTO>
     */
    @DatasourceSelector(sourceName = "clickhouse")
    List<MultiparatersDTO> getGraphList(@Param("taskId") Long taskId);

    /**
     * 获取value数据
     *
     * @param taskId 任务id
     * @return List<MultiparatersDTO>
     */
    @DatasourceSelector(sourceName = "clickhouse")
    List<MultiparatersDTO> getValueList(@Param("taskId") Long taskId);

    /**
     * 获取anomaly数据
     *
     * @param taskId 任务id
     * @return List<MultiparatersDTO>
     */
    @DatasourceSelector(sourceName = "clickhouse")
    List<MultiparatersDTO> getAnomalyList(@Param("taskId") Long taskId);

    /**
     * 获取slope数据
     *
     * @param taskId 任务id
     * @return List<MultiparatersDTO>
     */
    @DatasourceSelector(sourceName = "clickhouse")
    List<MultiparatersDTO> getSlopeList(Long taskId);

    /**
     * 插入双参数数据
     *
     * @param list 入参
     */
    @DatasourceSelector(sourceName = "clickhouse")
    void insertDiagnoseTwoParamsDataList(@Param("list") List<MultiparatersDTO> list);


    /**
     * 插入事后诊断预测数据
     *
     * @param diagnoseFaultDataList 诊断数据
     */
    @DatasourceSelector(sourceName = "clickhouse")
    void insertDiagnosePredictDataList(@Param("diagnoseFaultDataList") List<DiagnoseFaultData> diagnoseFaultDataList);

    /**
     * 获取预测数据
     *
     * @param taskChildId 字任务id
     * @return List<TaskResultVo>
     */
    @DatasourceSelector(sourceName = "clickhouse")
    List<TaskResultVo> getPredictDataList(@Param("taskChildId") Long taskChildId);

    /**
     * 单参数诊断数据插入
     *
     * @param missionGraphArrayList 入参
     */
    @DatasourceSelector(sourceName = "clickhouse")
    void insertDiagnoseSingleParameterDiagnosis(@Param("list") ArrayList<MultiparatersDTO> missionGraphArrayList);

    /**
     * 查询单参数诊断数据
     *
     * @param taskFaultPredictDataVo 故障预测数据
     * @return List<MultiparatersDTO>
     */
    @DatasourceSelector(sourceName = "clickhouse")
    List<MultiparatersDTO> selectCaseOneDataList(TaskFaultPredictDataVo taskFaultPredictDataVo);

    /**
     * 查询msg数据
     *
     * @param taskId 任务id
     * @return List<MultiparatersDTO>
     */
    @DatasourceSelector(sourceName = "clickhouse")
    List<MultiparatersDTO> getMsgList(Long taskId);


}
